//
//  NYLogoutManager.m
//  NOAHWM
//
//  Created by Ryan on 13-7-11.
//  Copyright (c) 2013年 Ryan. All rights reserved.
//

#import "NYLogoutManager.h"
#import "JSON.h"
#import "NYMemberCenterDataManager.h"

@implementation NYLogoutManager

+ (NYLogoutManager *)sharedManager
{
    static NYLogoutManager *manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[NYLogoutManager alloc] init];
    });
    return manager;
}

- (void)dealloc
{
    [[RYDownloaderManager sharedManager] cancelDownloaderWithDelegate:self purpose:nil];
    [super dealloc];
}

- (void)callServerToLogout
{
    NSString *suburl = [NSString stringWithFormat:kLogoutUrl,@"jsonp",[NYMemberCenterDataManager sharedManager].loginMember.loginLogId];
    suburl = [suburl stringByAppendingString:@"app000007"];
    NSString *url = [NSString stringWithFormat:@"%@%@",kServerAddress,suburl];
    url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    [[RYDownloaderManager sharedManager] requestDataByGetWithURLString:url delegate:self purpose:nil];
}

#pragma mark - RYDownloaderDelegate methods
- (void)downloader:(RYDownloader*)downloader completeWithNSData:(NSData*)data
{
//    NSString *str = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
//    str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
//    //去掉被包的jsonp字串
//    if(str.length > 7)
//        str = [str substringWithRange:NSMakeRange(6, str.length-7)];
//    NSDictionary *dict = [str JSONValue];

}
- (void)downloader:(RYDownloader*)downloader didFinishWithError:(NSString*)message
{
}

@end
